function select(limitLength, ifDeleteDirectly, ifPromoteItemLength) {
  // 转换单位
  function pointToMM(numIn) {
    return (numIn / 72) * 25.4;
  }
  function MMTopoint(numIn) {
    return (numIn / 25.4) * 72;
  }
  // 格式化数字
  function formatNumForOutput(numIn) {
    return parseFloat(trimEndZero(formatNum(numIn, 2)));
  }
  if (documents.length > 0) {
    var activeDocument = app.activeDocument;
    var elementsSelected = activeDocument.selection;
    var pathElements = activeDocument.pathItems;

    // 提示对象长度
    if (ifPromoteItemLength && elementsSelected.length === 1) {
      alert("当前选中对象的长度: " + trimEndZero(formatNum(pointToMM(elementsSelected[0].length), 5)) + " mm");
      return;
    } else if (ifPromoteItemLength) {
      alert("如果想要查看对象的周长，请只选择一个对象。\n考虑到插件的执行效率，不建议选择多个对象。");
      return;
    }

    // 取消全部选择
    if (elementsSelected.length > 0) {
      for (s = 0; s < elementsSelected.length; s++) {
        var selectedItem = elementsSelected[s];
        selectedItem.selected = false;
      }
    }

    // 选择路径对象
    if (pathElements.length > 0) {
      if (pathElements.length > 100) {
        alert("待处理对象数目: " + pathElements.length + "\n处理时间可能较长, 请耐心等待, 不要操作~");
      }
      // 选择覆合要求的对象
      for (i = 0; i < pathElements.length; i++) {
        var targetItem = pathElements[i];

        if (targetItem.length < MMTopoint(limitLength)) {
          // 删除选中对象
          if (ifDeleteDirectly) {
            i--;
            targetItem.remove();
          } else {
            targetItem.selected = true;
          }
        }
      }
    } else {
      alert("文档中不存在路径对象！");
    }
  } else {
    alert("请先打开一个文档!");
  }
}

function formatNum(numIn, accuracyIn) {
  var tempNum = numIn.toFixed(accuracyIn + 2).slice(0, -1);
  var tempNumString = "" + tempNum;
  var lastNum = parseInt(tempNumString.charAt(tempNumString.length - 1));
  if (lastNum != 0) {
    var zeroString = "";
    var tempString = "";
    for (k = 1; k < accuracyIn; k++) {
      zeroString += "0";
    }
    tempString = "0." + zeroString + "1";
    // 此时area为字符串
    numIn = numIn.toFixed(accuracyIn + 1).slice(0, -1);
    numIn = parseFloat(numIn) + parseFloat(tempString);
  } else {
    numIn = numIn.toFixed(accuracyIn + 1).slice(0, -1);
  }
  return numIn;
}

function trimEndZero(numIn) {
  var originString = "" + numIn;
  numIn = parseFloat(originString);
  return numIn;
}
